package spring.cloud.service.task.analyzer;

import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import spring.cloud.tasks.common.curator.Curator;
import spring.cloud.tasks.common.curator.CuratorInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * 不高可用 超时未跑 是否存在异常
 */
@Slf4j
@Setter
@Getter
public class AlarmAnalyzerModel {


    private OutdatedNoRunningTaskAnalyzer outdatedNoRunningJobAnalyzer;
    private TimeoutTaskAnalyzer timeout4AlarmJobAnalyzer;
    private UnableHaTaskAnalyzer unableHaTaskAnalyzer;

    public void analyzeUnableFailoverJob(CuratorInfo curatorInfo, Curator curator, String taskId) {
        final List<UnableHaTask> unableHaTaskList = new ArrayList<UnableHaTask>();
        unableHaTaskAnalyzer.analyzeUnableHaJob(curator, curatorInfo, unableHaTaskList, taskId);
    }

    public void analyzeOutdatedNoRunningTask(CuratorInfo curatorInfo, Curator curator, List<OutdatedNoRunningTaskTask> outdatedNoRunningTaskTaskList, String taskId) {
        outdatedNoRunningJobAnalyzer.analyzeOutdatedNoRunningTask(curatorInfo, curator, outdatedNoRunningTaskTaskList, taskId);
    }


    public void analyzeTimeout4AlarmJob(CuratorInfo curatorInfo, Curator curator, List<TimeoutTask> timeoutTaskList, String taskId) {

        timeout4AlarmJobAnalyzer.analyzeTimeoutTask(curatorInfo, curator, timeoutTaskList, taskId);
    }

}
